package com.pro.control;

import com.pro.entity.JsonData;
import com.pro.service.AersonnelStatisticsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

/**
 * @author ：刘弘禹
 * @description：TODO
 * @date ：2021/12/6 18:30
 */
@Controller
@RequestMapping("/Personnel")
public class AersonnelStatisticsController {
    @Autowired
    private AersonnelStatisticsService aersonnelStatisticsService;

    @RequestMapping("/getFrontEndNumber")
    @ResponseBody
    public JsonData getFrontEndNumber() {
        Integer frontEndNumber = aersonnelStatisticsService.getFrontEndNumber("js_before_user");
        return frontEndNumber > 0 ? JsonData.buildSuccess(frontEndNumber) : JsonData.buildError("服务器错误");
    }

    @RequestMapping("/getBackEndNumber")
    @ResponseBody
    public JsonData getBackEndNumber() {
        Integer frontEndNumber = aersonnelStatisticsService.getFrontEndNumber("js_user");
        return frontEndNumber > 0 ? JsonData.buildSuccess(frontEndNumber) : JsonData.buildError("服务器错误");
    }


    @RequestMapping("/getFrontMonthlyNumber")
    @ResponseBody
    public JsonData getFrontMonthlyNumber() {
        List monthlyNumber = aersonnelStatisticsService.getMonthlyNumber("js_before_user","create_date");
        return monthlyNumber != null ? JsonData.buildSuccess(monthlyNumber) : JsonData.buildError("服务器错误");
    }

    @RequestMapping("/getAfterMonthlyNumber")
    @ResponseBody
    public JsonData getAfterMonthlyNumber() {
        List monthlyNumber = aersonnelStatisticsService.getMonthlyNumber("js_user","register_date");
        return monthlyNumber != null ? JsonData.buildSuccess(monthlyNumber) : JsonData.buildError("服务器错误");
    }

    @RequestMapping("/getGetKeyword")
    @ResponseBody
    public JsonData getGetKeyword() {
        List<Map<String, Object>> getKeyword = aersonnelStatisticsService.getGetKeyword();
        return getKeyword != null ? JsonData.buildSuccess(getKeyword) : JsonData.buildError("服务器错误");
    }
}
